#include"comm.h"
int main()
{
  key_t k=ftok(PATHNAME,PROJ_ID);
  if(k<0)
  {
    printf("ftok error\n");
    return 1;
  }
  printf("%x\n",k);
  int shm=shmget(k,size,IPC_CREAT|IPC_EXCL|0666);//默认权限
  if(shm<0)
  {
    perror("shmget");
    return 2;
  }
  printf("%d\n",shm);
  char* mem=(char*)shmat(shm,NULL,0);
  while(1)
  {

    //读取共享内存
    printf("server receive:%s\n",mem);
    sleep(1);
  }

  sleep(2); 
  shmdt(mem);
  shmctl(shm,IPC_RMID,NULL);//删除共享内存
  return 0;
}
